
****************************************************
*** EXAMINE ISSUE ATTITUDES AND CONSTRUCT SCALES ***
****************************************************

use "${here}MICE2.dta", clear

keep genderid sexualid4 education income born_outside_canada indigenous racialized mother_tongue4 ///
	partyid voteintention votechoice ///
	immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy international_trade government_intervention income_inequality wealth_gap ///
	age4 pt user_language cps21_weight_general_all ///
	_mi _mj

mi import ice, automatic clear

*** EXAMINE RELATIONSHIPS AMONG ISSUE ATTITUDES
corr immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy international_trade government_intervention income_inequality wealth_gap if _mi_m ~= 0
alpha immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy government_intervention income_inequality wealth_gap if _mi_m ~= 0
factor immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy government_intervention income_inequality wealth_gap if _mi_m ~= 0

*** GENERATE LEFT-RIGHT SCALE
gen left = (immigration + refugees + jobs_vs_environment_pes + family_values + bilingualism + equal_rights + immigrant_integration + immigrant_jobs + abortion + conversion_therapy + government_intervention + income_inequality + wealth_gap) / 13

*** GENERATE IMMIGRATION SCALE
gen immigration_scale = (immigration + refugees + immigrant_integration + immigrant_jobs) / 4
alpha immigration refugees immigrant_integration immigrant_jobs
factor immigration refugees immigrant_integration immigrant_jobs

*** GENERATE REDISTRIBUTION/INEQUALITY SCALE
gen redistribution_scale = (income_inequality + wealth_gap) / 2
alpha income_inequality wealth_gap

*** GENERATE TRADITIONALISM SCALE
gen traditionalism_scale = (family_values + equal_rights) / 2
alpha family_values equal_rights

*** GENERATE VECTOR OF DUMMY VARIABLES FOR PARTY IDENTIFICATION
tab partyid, gen(pid_)

*** GENERATE VECTOR OF DUMMY VARIABLES FOR VOTE CHOICE
tab votechoice, gen(vote_)

*** RECODE INCOME
recode income (1=2)
gen income7 = income - 1
label variable income7 "Income"

************************************
*** LIBERAL PARTY IDENTIFICATION ***
************************************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit pid_1 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit pid_1 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit pid_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR LIBERAL PARTY IDENTIFICATION
preserve
use "Model1IssuesLiberalPartyID", clear
append using "Model2IssuesLiberalPartyID"
append using "Model3IssuesLiberalPartyID"
append using "Model4IssuesLiberalPartyID"
append using "Model5IssuesLiberalPartyID"
append using "Model6IssuesLiberalPartyID"
append using "Model7IssuesLiberalPartyID"
append using "Model8IssuesLiberalPartyID"
append using "Model9IssuesLiberalPartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN LIBERAL PARTY IDENTIFICATION ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xlabel(-30(10)0) ///
	xscale(range(-35 5)) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Liberal" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesLiberalPID_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(-35 5)) ///
	xlabel(-30(10)0) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Liberal" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesLiberalPID_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesLiberalPID_NonbinaryVSMan.gph IssuesLiberalPID_NonbinaryVSWoman.gph, col(2)
graph export "IssuesLiberalPID_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

*****************************************
*** CONSERVATIVE PARTY IDENTIFICATION ***
*****************************************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit pid_2 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit pid_2 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit pid_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR CONSERVATIVE PARTY IDENTIFICATION
preserve
use "Model1IssuesConservativePartyID", clear
append using "Model2IssuesConservativePartyID"
append using "Model3IssuesConservativePartyID"
append using "Model4IssuesConservativePartyID"
append using "Model5IssuesConservativePartyID"
append using "Model6IssuesConservativePartyID"
append using "Model7IssuesConservativePartyID"
append using "Model8IssuesConservativePartyID"
append using "Model9IssuesConservativePartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN CONSERVATIVE PARTY IDENTIFICATION ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xlabel(-30(10)0) ///
	xscale(range(-35 5)) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Conservative" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesConservativePID_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(-35 5)) ///
	xlabel(-30(10)0) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Conservative" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesConservativePID_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesConservativePID_NonbinaryVSMan.gph IssuesConservativePID_NonbinaryVSWoman.gph, col(2)
graph export "IssuesConservativePID_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

********************************
*** NDP PARTY IDENTIFICATION ***
********************************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit pid_3 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit pid_3 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit pid_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR NDP PARTY IDENTIFICATION
preserve
use "Model1IssuesNDPPartyID", clear
append using "Model2IssuesNDPPartyID"
append using "Model3IssuesNDPPartyID"
append using "Model4IssuesNDPPartyID"
append using "Model5IssuesNDPPartyID"
append using "Model6IssuesNDPPartyID"
append using "Model7IssuesNDPPartyID"
append using "Model8IssuesNDPPartyID"
append using "Model9IssuesNDPPartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN NDP PARTY IDENTIFICATION ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xscale(range(0 65)) ///
	xlabel(0(20)60) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("NDP" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesNDPPID_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(0 65)) ///
	xlabel(0(20)60) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("NDP" "Party Identification", size(medsmall)) ///
	legend(off)
graph save IssuesNDPPID_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesNDPPID_NonbinaryVSMan.gph IssuesNDPPID_NonbinaryVSWoman.gph, col(2)
graph export "IssuesNDPPID_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

***************************
*** LIBERAL VOTE CHOICE ***
***************************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit vote_1 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit vote_1 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit vote_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesLiberalPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR LIBERAL VOTE CHOICE
preserve
use "Model1IssuesLiberalPartyID", clear
append using "Model2IssuesLiberalPartyID"
append using "Model3IssuesLiberalPartyID"
append using "Model4IssuesLiberalPartyID"
append using "Model5IssuesLiberalPartyID"
append using "Model6IssuesLiberalPartyID"
append using "Model7IssuesLiberalPartyID"
append using "Model8IssuesLiberalPartyID"
append using "Model9IssuesLiberalPartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN LIBERAL VOTE CHOICE ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xlabel(-30(10)0) ///
	xscale(range(-35 5)) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Liberal" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesLiberalVoteChoice_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(-35 5)) ///
	xlabel(-30(10)0) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Liberal" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesLiberalVoteChoice_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesLiberalVoteChoice_NonbinaryVSMan.gph IssuesLiberalVoteChoice_NonbinaryVSWoman.gph, col(2)
graph export "IssuesLiberalVoteChoice_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

********************************
*** CONSERVATIVE VOTE CHOICE ***
********************************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit vote_2 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit vote_2 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit vote_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesConservativePartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR CONSERVATIVE VOTE CHOICE
preserve
use "Model1IssuesConservativePartyID", clear
append using "Model2IssuesConservativePartyID"
append using "Model3IssuesConservativePartyID"
append using "Model4IssuesConservativePartyID"
append using "Model5IssuesConservativePartyID"
append using "Model6IssuesConservativePartyID"
append using "Model7IssuesConservativePartyID"
append using "Model8IssuesConservativePartyID"
append using "Model9IssuesConservativePartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN CONSERVATIVE VOTE CHOICE ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xlabel(-30(10)0) ///
	xscale(range(-35 5)) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Conservative" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesConservativeVoteChoice_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(-35 5)) ///
	xlabel(-30(10)0) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("Conservative" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesConservativeVoteChoice_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesConservativeVoteChoice_NonbinaryVSMan.gph IssuesConservativeVoteChoice_NonbinaryVSWoman.gph, col(2)
graph export "IssuesConservativeVoteChoice_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

***********************
*** NDP VOTE CHOICE ***
***********************

** MODEL 1: SIMPLE BIVARIATE MODEL
mi estimate: logit vote_3 i.genderid [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model1IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (1) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 2: LIKELY PRIOR DEMOGRAPHICS ONLY
mi estimate: logit vote_3 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model2IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (2) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 3: ALL DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model3IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (3) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 4: CONVERSION THERAPY, NO DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model4IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (4) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 5: LEFT-RIGHT SCALE, NO DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid c.left [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model5IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (5) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 6: DETAILED ISSUES, NO DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model6IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (6) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 7: CONVERSION THERAPY, WITH DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid i.conversion_therapy i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model7IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (7) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** MODEL 8: LEFT-RIGHT SCALE + DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid c.left i.age4 i.education c.income7 i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model8IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (8) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

** MODEL 9: DETAILED ISSUES, WITH DEMOGRAPHICS
mi estimate: logit vote_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale traditionalism_scale jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income7 i.i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
mimrgns i.genderid , predict(pr) pwcompare

tempname memhold
postfile `memhold' Model Gap1 Gap2 Gap3 Lower1 Lower2 Lower3 Upper1 Upper2 Upper3 p1 p2 p3 ///
	using "Model9IssuesNDPPartyID", replace 

	matrix row = r(table_vs)
	local diff1 = row[1,1]
	local diff2 = row[1,2]
	local diff3 = row[1,3]
	local lower1 = row[5,1]
	local lower2 = row[5,2]
	local lower3 = row[5,3]
	local upper1 = row[6,1]
	local upper2 = row[6,2]
	local upper3 = row[6,3]
	local p1 = row[4,1]
	local p2 = row[4,2]
	local p3 = row[4,3]
post `memhold' (9) (`diff1') (`diff2') (`diff3') ///
				(`lower1') (`lower2') (`lower3') ///
				(`upper1') (`upper2') (`upper3') ///
				(`p1') (`p2') (`p3')
postclose `memhold'

*** GRAPH MODELS FOR NDP VOTE CHOICE
preserve
use "Model1IssuesNDPPartyID", clear
append using "Model2IssuesNDPPartyID"
append using "Model3IssuesNDPPartyID"
append using "Model4IssuesNDPPartyID"
append using "Model5IssuesNDPPartyID"
append using "Model6IssuesNDPPartyID"
append using "Model7IssuesNDPPartyID"
append using "Model8IssuesNDPPartyID"
append using "Model9IssuesNDPPartyID"

*** CHECK RELATIVE SIZE OF GAPS
gen BiggerGap2 = 0
replace BiggerGap2 = 1 if abs(Gap2) > abs(Gap1)
tab BiggerGap2

gen BiggerGap3 = 0
replace BiggerGap3 = 1 if abs(Gap3) > abs(Gap1)
tab BiggerGap3

*** DROP THESE VARIABLES FOR RESHAPING
drop BiggerGap2 BiggerGap3

*** RESHAPE FROM MODEL-LEVEL TO MODEL-COMPARISON-LEVEL
reshape long Gap Lower Upper p, i(Model) j(Comparison)

*** LABEL COMPARISONS
label define comparisons 1 "Woman-Man" 2 "Nonbinary-Man" 3 "Nonbinary-Woman"
label values Comparison comparisons

*** CONVERT ESTIMATES FROM PROPORTIONS TO PERCENTAGES
replace Gap = Gap * 100
gen Lower95 = Lower * 100
gen Upper95 = Upper * 100
gen Lower90 = Gap - ((Gap - Lower95) * 0.837)
gen Upper90 = Gap + ((Upper95 - Gap) * 0.837)

*** CODE SIGNIFICANCE AT P < 0.1
gen Sig90 = 0
replace Sig90 = 1 if p < 0.1

*** CODE SIGNIFICANCE AT P < 0.05
gen Sig95 = 0
replace Sig95 = 1 if p < 0.05

*** LOOK AT SIGNIFICANCE BY COMPARISON
tab Comparison Sig90
tab Comparison Sig95
*** ALL GAPS IN NDP VOTE CHOICE ARE SIGNIFICANT

*** REPLACE NUMBERS AND GENERATE VALUE LABELS
gen ModelLabelled = (Model - 10) * -1

label define models ///
			1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls"
label values ModelLabelled models
			
*** GRAPH COMPARISONS
graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 2, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 2, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 2, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Man") ///
	xscale(range(0 65)) ///
	xlabel(0(20)60) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("NDP" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesNDPVoteChoice_NonbinaryVSMan.gph, replace	

graph twoway ///
	(scatter ModelLabelled Gap if Comparison == 3, mcolor(black) msymbol(Oh) mlabel(Gap) mlabposition(12) mlabcolor(black) mlabformat(%9.1f)) ///
	(rspike Lower90 Upper90 ModelLabelled if Comparison == 3, lcolor(black) lwidth(medthick) horizontal) ///
	(rspike Lower95 Upper95 ModelLabelled if Comparison == 3, lcolor(black) lwidth(thin) horizontal), ///
	ytitle("") ///
	ylabel(1 "All Demographics + Issue Attitudes" ///
			2 "All Demographics + Left-Right Scale" ///
			3 "All Demographics + Conversion Therapy" ///
			4 "Issue Attitudes Only" ///
			5 "Left-Right Scale Only" ///
			6 "Conversion Therapy Only" ///
			7 "All Demographics" ///
			8 "Prior Demographics" ///
			9 "No Controls") ///
	yscale(range(0.8 9.2)) ///
	xtitle("Nonbinary-Woman") ///
	xscale(range(0 65)) ///
	xlabel(0(20)60) ///
	xline(0, lcolor(gs14) lpattern(solid)) ///
	title("NDP" "Vote Choice", size(medsmall)) ///
	legend(off)
graph save IssuesNDPVoteChoice_NonbinaryVSWoman.gph, replace	
restore

graph combine IssuesNDPVoteChoice_NonbinaryVSMan.gph IssuesNDPVoteChoice_NonbinaryVSWoman.gph, col(2)
graph export "IssuesNDPVoteChoice_NineModels_SupplementaryMaterials.png", height(1400) width(2400) replace

